package com.example.hulixia.myapplication;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;

/**
 * Created by hulixia on 2018/10/15.
 */

public class EditActivity extends AppCompatActivity {
    private EditText edtName;
    private EditText edtAge;
    private RadioButton radioButton1;
    private RadioButton radioButton2;
    private RadioButton radioButton3;
    private RadioButton radioButton4;
    private RadioButton radioButton5;
    private Button btnSave;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edit);

        setTitle("编辑学生");

        Intent intent = getIntent();
        String name = intent.getStringExtra("NAME");
        int age = intent.getIntExtra("AGE", 0);
        int imgId = intent.getIntExtra("IMGID", R.drawable.dog1);

        edtName = findViewById(R.id.edtName);
        edtAge =findViewById(R.id.edtAge);

        radioButton1 = findViewById(R.id.radioBtn1);
        radioButton2 = findViewById(R.id.radioBtn2);
        radioButton3 = findViewById(R.id.radioBtn3);
        radioButton4 = findViewById(R.id.radioBtn4);
        radioButton5 = findViewById(R.id.radioBtn5);

        edtName.setText(name);
        edtAge.setText(String.valueOf(age));

        switch (imgId){
            case R.drawable.dog1:
                radioButton1.setChecked(true);
                break;

            case R.drawable.dog2:
                radioButton2.setChecked(true);
                break;

            case R.drawable.dog3:
                radioButton3.setChecked(true);
                break;

            case R.drawable.dog4:
                radioButton3.setChecked(true);
                break;

            case R.drawable.dog5:
                radioButton5.setChecked(true);
                break;
        }



    }
}